package com.bugreport.utils;

import org.apache.log4j.Logger;

public class BugReportException extends Exception {

	private static final Logger logger = Logger.getLogger(BugReportException.class);

	private static final long serialVersionUID = 1115058231428797401L;

	private int code;
	private String message;

	public BugReportException(int code, String... args) {

		this.code = code;

		if (MessageFactory.getInstance() != null) {
			this.message = MessageFactory.getInstance().getMessage(String.valueOf(code), args);
		} else {
			this.message = "!!! No access to MessageFactory = no message but error code " + code + "  is right !!!";
			logger.fatal(this.message);
		}
	}

	public BugReportException(int code, Throwable cause, String... args) {
		this(code, args);
		super.initCause(cause);
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}
}
